<!doctype html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>四大天王</title>
    <style>
        *{
            margin:0;
            padding: 0;
        }
        ul{
            list-style: none;
        }

        li{
            width: 200px;
            float:left;
            margin-right: 10px;
        }
        li img{
            width: 100%;
        }
        .clear{
            clear:both;
        }
        #show{
            width: 400px;
            height: 400px;
            background: #eaf;
        }
    </style>
</head>
<body>
    <ul>
        <li><img src="./images/liudehua.jpg" alt=""></li>
        <li><img src="./images/guofucheng.jpg" alt=""></li>
        <li><img src="./images/liming.jpg" alt=""></li>
        <li><img src="./images/zhangxueyou.jpg" alt=""></li>
    </ul>
    <div class="clear"></div>
    <div id="show"></div>

    <script>
        console.log('布局视口的宽度'+document.documentElement.clientWidth);
        console.log('视觉视口的宽度'+window.innerWidth);

        let show = document.querySelector('#show');

        //定时器 每过50毫秒获取一次 并设置文本
        setInterval(() => {
            show.innerHTML = `
                布局视口: ${document.documentElement.clientWidth}<br/>
                视觉视口: ${window.visualViewport.width}
            `
        }, 50)
    </script>
</body>
</html>